import axios from "axios";
import { CHANGE_LOGIN, LOGOUT } from "./actionTypes";

const changeLogin = (data) => ({
    type: CHANGE_LOGIN,
    data
})

export const logout = () => ({
    type: LOGOUT,
    value: false
})

export const login = (account, password) => {
    return (dispatch) => {
        axios.get('/api/login.json?account='+account+'?password='+password)
        .then(
            res => {
                const result = res.data.data
                dispatch(changeLogin(result))
            }
        )
    }


}